package java_design_model.com.Memento;

public class O {
    int state=0;//状态值
    IS is;//备忘录
    O(IS is){
        this.is=is;
    }
    void addstate(){

        state++;
        change();
        show();
    }
    void backstate(){

        state=is.getLastNode().getState();
        change();
        show();
    }
    void change(){
        is.addNode(new INode(state));
    }
    void show(){
        System.out.println(state);
    }
    public int getState() {
        return state;
    }
}
